package com.cln.fibonacci;

import junit.framework.TestCase;

public class TestFib extends TestCase {

	public void testPhi() {
		int cases[][] = { { 0, 0 }, { 1, 1 }, { 2, 1 }, { 3, 2 }, { 4, 3 },
				{ 5, 5 } };
		for (int i = 0; i < cases.length; i++)
			assertEquals(cases[i][1], phi(cases[i][0]));
	}

	private int phi(int i) {
		if (i == 0)
			return 0;
		if (i == 1)// phi(2)=phi(1)+phi(0)=phi(1)
			return 1;
		return phi(i - 1) + phi(i - 2);
	}
}
